
/**************************************************************************************************/
/*******                                                                                     ******/
/**************************************************************************************************/


DM'CLEAR LOG';DM'CLEAR OUTPUT';DM odsresults 'clear';
PROC DATASETS KILL LIB=WORK;QUIT;
OPTIONS FORMDLIM='-';
OPTIONS FORMDLIM='-';


/**************************************************************************************************/
/*******                                                                                     ******/
/**************************************************************************************************/


PROC IMPORT OUT= WORK.AGYW_PrEPDATA
            DATAFILE= "H:\AGYWPrEP_DATA.csv" 
            DBMS=csv 
           REPLACE;
           GETNAMES=YES;
RUN;



/**************************************************************************************************/
/*******                                                                                     ******/
/**************************************************************************************************/


proc contents data=AGYW_PrEPDATA;run;



/**************************************************************************************************/
/*******                                                 MACROS                              ******/
/**************************************************************************************************/


%MACRO FREQ_OVERALL(NUM,DSET,OUTCOME);
data TEMP; set &DSET;WHERE NOT MISSING(&OUTCOME);
STRATA=&OUTCOME;
RUN;
proc freq data=TEMP; table STRATA/missing;ODS OUTPUT OneWayFreqs=nfreqA;run;
DATA FREQ0; set nfreqA; keep STRATA Frequency Percent;run;
DATA FREQ&NUM; LENGTH VAR $ 30.;SET FREQ0;
VAR=SUBSTR("&OUTCOME",1);
NUM=&NUM;
RUN;
%MEND FREQ_OVERALL;

%MACRO MEAN_OVERALL(NUM,DSET,OUTCOME);
data TEMP; set &dset;WHERE NOT MISSING(&OUTCOME);
OUTCOME=&OUTCOME;
RUN;
PROC MEANS DATA=TEMP N Mean STD Median Q1 Q3 MIN MAX MAXDEC=2 NOPRINT; 
VAR OUTCOME;
OUTPUT OUT=MEANA  N=N  MEAN=MEAN STD=STD Median=MED Q1=Q1 Q3=Q3 MIN=MIN MAX=MAX;
RUN;
DATA MEANS0; SET MEANA;RUN;
DATA MEAN&NUM; LENGTH VAR $ 30.;SET MEANS0;
VAR=SUBSTR("&OUTCOME",1);
NUM=&NUM;
DROP _TYPE_ _FREQ_;
RUN;
%MEND MEAN_OVERALL;

%MACRO ODDS_RATIOS_GEE(NUM,DSET,OUTCOME,COVARIATE,ADJCLASS,ADJCONT);
DATA TEMP;SET &DSET;WHERE  NOT MISSING(&OUTCOME) AND &OUTCOME in (0,1) AND NOT MISSING(&COVARIATE);
COVAR= &COVARIATE;
OUTCOME=&OUTCOME;
RUN;
proc logistic data=temp;
class COVAR(ref=first param=ref);
model OUTCOME(event='1')= COVAR;
ods output ParameterEstimates=parmest_logit;
run;
proc genmod data=temp;
class ward COVAR (ref=first param=ref);
model outcome(event='1')=COVAR/dist=bin link=logit;
repeated subject=ward/corr=exch;
ods output GEEEmpPEst=parmest_gee_unadj;
run;
proc genmod data=temp;
class ward  &ADJCLASS COVAR (ref=first param=ref);
model outcome(event='1')=COVAR &ADJCLASS &ADJCONT/dist=bin link=logit;
repeated subject=ward/corr=exch;
ods output GEEEmpPEst=parmest_gee;
run;
DATA ORs_logit;SET parmest_logit;WHERE Variable in ('COVAR');
COVAR=ClassVal0+0;
OR_logit=exp(Estimate);
LL_logit=exp(Estimate-1.96*StdErr);
UL_logit=exp(Estimate+1.96*StdErr);
P_logit=ProbChiSq;
Method='logistic';
KEEP COVAR OR_logit LL_logit UL_logit P_logit;RUN;

DATA ORs_gee_unadj;SET parmest_gee_unadj;WHERE Parm in ('COVAR');
COVAR=Level1+0;
OR_gee_unadj=exp(Estimate);
LL_gee_unadj=exp(Estimate-1.96*StdErr);
UL_gee_unadj=exp(Estimate+1.96*StdErr);
P_gee_unadj=ProbZ;
Method='GEE_unadj';
KEEP COVAR OR_gee_unadj LL_gee_unadj UL_gee_unadj P_gee_unadj;RUN;

DATA ORs_gee;SET parmest_gee;WHERE Parm in ('COVAR');
COVAR=Level1+0;
OR_gee=exp(Estimate);
LL_gee=exp(Estimate-1.96*StdErr);
UL_gee=exp(Estimate+1.96*StdErr);
P_gee=ProbZ;
Method='GEE';
KEEP COVAR OR_gee LL_gee UL_gee P_gee;RUN;

DATA ORs_all;merge ors_logit ors_gee_unadj ors_gee;by covar;RUN;

proc freq data=TEMP; table OUTCOME;ODS OUTPUT  OneWayFreqs=nfreq_outcome;run;
DATA event_0;set nfreq_outcome;where OUTCOME=0;Total_0=Frequency;NUM=&NUM;KEEP NUM Total_0;RUN;
DATA event_1;set nfreq_outcome;where OUTCOME=1;Total_1=Frequency;NUM=&NUM;KEEP NUM Total_1;RUN;
DATA events;merge event_0 event_1;by NUM;RUN;

proc sort data=temp;by outcome;run;
proc freq data=TEMP; table COVAR;by OUTCOME;ODS OUTPUT  OneWayFreqs=nfreq_covar;run;
DATA nfreqs_covar;SET nfreq_covar;N=Frequency;Percent=Percent;KEEP NUM OUTCOME COVAR N Percent;RUN;
DATA nfreqs_0;SET nfreqs_covar;where OUTCOME=0;N_0=N;Percent_0=Percent;KEEP COVAR N_0 Percent_0;PROC SORT;BY COVAR;RUN;
DATA nfreqs_1;SET nfreqs_covar;where OUTCOME=1;N_1=N;Percent_1=Percent;KEEP COVAR N_1 Percent_1;PROC SORT;BY COVAR;RUN;
DATA nfreqs_covall;merge nfreqs_0 nfreqs_1;BY covar;NUM=&NUM;run;
DATA nfreqs_all;MERGE nfreqs_covall events;BY NUM;RUN;

DATA nfreqs_all;SET nfreqs_all;
prop_0=percent_0/100;
prop_1=percent_1/100;
var_0=prop_0*(1-prop_0)/Total_0;
var_1=prop_1*(1-prop_1)/Total_1;
LL_prop_0=prop_0-1.96*sqrt(var_0);
UL_prop_0=prop_0+1.96*sqrt(var_0);
LL_prop_1=prop_1-1.96*sqrt(var_1);
UL_prop_1=prop_1+1.96*sqrt(var_1);
log_0=log(prop_0/(1-prop_0));
log_1=log(prop_1/(1-prop_1));
Slog_0=sqrt(var_0)/(prop_0*(1-prop_0));
Slog_1=sqrt(var_1)/(prop_1*(1-prop_1));
llog_0=log_0-1.96*Slog_0;
ulog_0=log_0+1.96*Slog_0;
llog_1=log_1-1.96*Slog_1;
ulog_1=log_1+1.96*Slog_1;
LL_prop_logit_0=1/(1+exp(-llog_0));
UL_prop_logit_0=1/(1+exp(-ulog_0));
LL_prop_logit_1=1/(1+exp(-llog_1));
UL_prop_logit_1=1/(1+exp(-ulog_1));
LL_percent_0=100*LL_prop_0;
UL_percent_0=100*UL_prop_0;
LL_percent_1=100*LL_prop_1;
UL_percent_1=100*UL_prop_1;
LL_percent_logit_0=100*LL_prop_logit_0;
UL_percent_logit_0=100*UL_prop_logit_0;
LL_percent_logit_1=100*LL_prop_logit_1;
UL_percent_logit_1=100*UL_prop_logit_1;
RUN;

DATA nfreqs_ORs;MERGE  nfreqs_all ORS_all;BY COVAR;RUN;
DATA OR&NUM; LENGTH COVARIATE $ 50.;SET nfreqs_ORs;
COVARIATE=SUBSTR("&COVARIATE",1);
RUN;
%MEND ODDS_RATIOS_GEE;


%MACRO GEE_MULTIVARIABLE(NUM,DSET,OUTCOME,INDCLASSCOV);
DATA TEMPM;SET &DSET;WHERE  NOT MISSING(&OUTCOME) AND &OUTCOME in (0,1);
OUTCOME=&OUTCOME;
RUN;
proc genmod data=tempm namelen=120;
class ward  &INDCLASSCOV kisumu /param=ref ref=first;
model outcome(event='1')= kisumu &INDCLASSCOV /dist=bin link=logit;
repeated subject=ward/corr=exch;
ods output GEEEmpPEst=parmest_gee_multiple;
run;
DATA ORs_gee_multiple;SET parmest_gee_multiple;WHERE Parm NOT in ("Intercept");
LENGTH COVAR $ 50.;
COVAR=Parm;
OR_gee_mult=exp(Estimate);
LL_gee_mult=exp(Estimate-1.96*StdErr);
UL_gee_mult=exp(Estimate+1.96*StdErr);
OR_CI_gee_mult=catx('',round(or_gee_mult,0.01),'[',round(ll_gee_mult,0.01),',',round(ul_gee_mult,0.01),']');
P_gee_mult=ProbZ;
KEEP COVAR OR_gee_mult LL_gee_mult UL_gee_mult OR_CI_gee_mult P_gee_mult ;RUN;
DATA SELECT&NUM;LENGTH VAR $ 35.;SET ORs_gee_multiple;
VAR=SUBSTR("&OUTCOME",1);
NUM=&NUM;
RUN;
%MEND GEE_MULTIVARIABLE;



/*********************************************************************************************************************/
/*****        Characteristics of participants - categorical variable  overall                                  *******/
/*********************************************************************************************************************/


%FREQ_OVERALL(1,AGYW_PrEPDATA,kisumu);
%FREQ_OVERALL(2,AGYW_PrEPDATA,Q2Age_t1);
%FREQ_OVERALL(3,AGYW_PrEPDATA,primary);
%FREQ_OVERALL(4,AGYW_PrEPDATA,secondary);
%FREQ_OVERALL(5,AGYW_PrEPDATA,secondaryplus);
%FREQ_OVERALL(6,AGYW_PrEPDATA,Student_current_t1);
%FREQ_OVERALL(7,AGYW_PrEPDATA,PrEP_adherencesupport);

%FREQ_OVERALL(8,AGYW_PrEPDATA,Partner_current_t1);
%FREQ_OVERALL(9,AGYW_PrEPDATA,Partner_cat3_t1);
%FREQ_OVERALL(10,AGYW_PrEPDATA,Married_cohabiting_t1);
%FREQ_OVERALL(11,AGYW_PrEPDATA,anykids);
%FREQ_OVERALL(12,AGYW_PrEPDATA,Live_withrelatives_t1);
%FREQ_OVERALL(13,AGYW_PrEPDATA,Live_withpartner_t1);
%FREQ_OVERALL(14,AGYW_PrEPDATA,Partner_hasmultiplepartners_t1);
%FREQ_OVERALL(15,AGYW_PrEPDATA,Partner_riskybehavior_t1);

%FREQ_OVERALL(16,AGYW_PrEPDATA,Contraceptive_use_t1);
%FREQ_OVERALL(17,AGYW_PrEPDATA,Contraceptive_oral_t1);
%FREQ_OVERALL(18,AGYW_PrEPDATA,Contraceptive_injectable_t1);
%FREQ_OVERALL(19,AGYW_PrEPDATA,Contraceptive_implant_t1);
%FREQ_OVERALL(20,AGYW_PrEPDATA,Contraceptive_malecondom_t1);
%FREQ_OVERALL(21,AGYW_PrEPDATA,Contraceptive_femalecondom_t1);
%FREQ_OVERALL(22,AGYW_PrEPDATA,Contraceptive_other_t1);
%FREQ_OVERALL(23,AGYW_PrEPDATA,Condom_alwaysuse_t1);
%FREQ_OVERALL(24,AGYW_PrEPDATA,Condom_inconsistuse_t1);

%FREQ_OVERALL(25,AGYW_PrEPDATA,Partner_knows_t1);
%FREQ_OVERALL(26,AGYW_PrEPDATA,Partner_verysupportive_t1);
%FREQ_OVERALL(27,AGYW_PrEPDATA,Partner_awareverysupportive_t1);
%FREQ_OVERALL(28,AGYW_PrEPDATA,Partner_hivunknown_t1);
%FREQ_OVERALL(29,AGYW_PrEPDATA,Partner_hivpositive_t1);
%FREQ_OVERALL(30,AGYW_PrEPDATA,Partner_hivpositiveunknown_t1);

%FREQ_OVERALL(31,AGYW_PrEPDATA,ipvatrisk_t1);
%FREQ_OVERALL(32,AGYW_PrEPDATA,HIVchancemoderate_t1);
%FREQ_OVERALL(33,AGYW_PrEPDATA,alcohol_cat2_t1);
%FREQ_OVERALL(34,AGYW_PrEPDATA,depress_moderatesevere_t1);
%FREQ_OVERALL(35,AGYW_PrEPDATA,depscore_cat3_t1);
%FREQ_OVERALL(36,AGYW_PrEPDATA,Q2ssscore_percent_t1);

%FREQ_OVERALL(37,AGYW_PrEPDATA,Months_2to3_since_initiation_t1);
%FREQ_OVERALL(38,AGYW_PrEPDATA,Months_3to6_since_initiation_t1);
%FREQ_OVERALL(39,AGYW_PrEPDATA,Months_6plus_since_initiation_t1);

DATA FREQS_table1;SET FREQ1 FREQ2 FREQ3 FREQ4 FREQ5 FREQ6 FREQ7 FREQ8 FREQ9 FREQ10 
                      FREQ11 FREQ12 FREQ13 FREQ14 FREQ15 FREQ16 FREQ17 FREQ18 FREQ19 FREQ20 
                      FREQ21 FREQ22 FREQ23 FREQ24 FREQ25 FREQ26 FREQ27 FREQ28 FREQ29 FREQ30 
                      FREQ31 FREQ32 FREQ33 FREQ34 FREQ35 FREQ36  FREQ37 FREQ38 FREQ39;
RUN;


proc print data=FREQS_table1;run;



PROC REPORT DATA=FREQS_table1 NOWD HEADLINE HEADSKIP CENTER MISSING;WHERE STRATA=1;
COLUMN VAR  (Frequency  percent);
DEFINE VAR/GROUP  ORDER=DATA ;
DEFINE Frequency/GROUP FORMAT=3. 'N';
DEFINE percent/GROUP FORMAT=4.1 'col %';
RUN;

PROC REPORT DATA=FREQS_table1 NOWD HEADLINE HEADSKIP CENTER MISSING;
COLUMN VAR strata (Frequency  percent);
DEFINE VAR/GROUP  ORDER=DATA ;
DEFINE Strata/GROUP  ORDER=DATA ;
DEFINE Frequency/GROUP FORMAT=3. 'N';
DEFINE percent/GROUP FORMAT=4.1 'col %';
RUN;



/*********************************************************************************************************************/
/*****        Characteristics of participants at Timepoint1 - continuous variable  overall                     *******/
/*********************************************************************************************************************/
  

%MEAN_OVERALL(1,AGYW_PrEPDATA,AGE_t1);
%MEAN_OVERALL(2,AGYW_PrEPDATA,Days_since_enrollment_t1);
%MEAN_OVERALL(3,AGYW_PrEPDATA,Days_since_initiation_t1);
%MEAN_OVERALL(4,AGYW_PrEPDATA,Days_btw_interviews);
DATA MEANS_Table1;SET MEAN1 MEAN2 MEAN3 MEAN4 ;RUN;


PROC REPORT DATA=MEANS_table1  NOWD HEADLINE HEADSKIP CENTER MISSING;
COLUMN VAR  (Mean STD) Med Q1 Q3;
DEFINE VAR/GROUP  ORDER=DATA ;
DEFINE mean/GROUP FORMAT=5.2 'Mean';
DEFINE STD/GROUP FORMAT=5.2 'SD';
DEFINE MED/GROUP FORMAT=5.2 'Med';
DEFINE Q1/GROUP FORMAT=5.2 'Q1';
DEFINE Q3/GROUP FORMAT=5.2 'Q3';
RUN;


/*********************************************************************************************************************/
/*****        Association of Characteristics  of AGYW at Timepoint2 with persistance wihout prep   Table 2   *******/
/*********************************************************************************************************************/

%ODDS_RATIOS_GEE(641,AGYW_PrEPDATA,PERSISTED_noprep,Q2Age_t1,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(642,AGYW_PrEPDATA,PERSISTED_noprep,DREAMS_active_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(643,AGYW_PrEPDATA,PERSISTED_noprep,Partner_current_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(644,AGYW_PrEPDATA,PERSISTED_noprep,Partner_multiple_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(645,AGYW_PrEPDATA,PERSISTED_noprep,Married_cohabiting_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(646,AGYW_PrEPDATA,PERSISTED_noprep,anykids,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(647,AGYW_PrEPDATA,PERSISTED_noprep,Live_withrelatives_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(648,AGYW_PrEPDATA,PERSISTED_noprep,Live_withpartner_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(649,AGYW_PrEPDATA,PERSISTED_noprep,Partner_knows_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(650,AGYW_PrEPDATA,PERSISTED_noprep,Partner_verysupportive_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(651,AGYW_PrEPDATA,PERSISTED_noprep,Partner_hivpositive_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(652,AGYW_PrEPDATA,PERSISTED_noprep,Partner_hasmultiplepartners_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(653,AGYW_PrEPDATA,PERSISTED_noprep,Partner_riskybehavior_t2,%STR(Kisumu),%STR());


%ODDS_RATIOS_GEE(654,AGYW_PrEPDATA,PERSISTED_noprep,HIVchance_modhigh_noprep_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(655,AGYW_PrEPDATA,PERSISTED_noprep,ipvatrisk_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(656,AGYW_PrEPDATA,PERSISTED_noprep,depress_moderatesevere_t2,%STR(Kisumu),%STR());

%ODDS_RATIOS_GEE(657,AGYW_PrEPDATA,PERSISTED_noprep,Q2ssscore_percent_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(658,AGYW_PrEPDATA,PERSISTED_noprep,Condom_alwaysuse_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(659,AGYW_PrEPDATA,PERSISTED_noprep,Condom_inconsistuse_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(660,AGYW_PrEPDATA,PERSISTED_noprep,condoms_useless_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(661,AGYW_PrEPDATA,PERSISTED_noprep,Contraceptive_use_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(662,AGYW_PrEPDATA,PERSISTED_noprep,Contraceptive_oral_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(663,AGYW_PrEPDATA,PERSISTED_noprep,Contraceptive_injectable_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(664,AGYW_PrEPDATA,PERSISTED_noprep,Contraceptive_implant_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(665,AGYW_PrEPDATA,PERSISTED_noprep,Contraceptive_malecondom_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(666,AGYW_PrEPDATA,PERSISTED_noprep,Contraceptive_femalecondom_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(667,AGYW_PrEPDATA,PERSISTED_noprep,Friends_onprep_t2,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(668,AGYW_PrEPDATA,PERSISTED_noprep,PrEP_toldsomeone_t2,%STR(Kisumu),%STR());

%ODDS_RATIOS_GEE(669,AGYW_PrEPDATA,PERSISTED_noprep,Months_2to3_since_initiation_t1,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(670,AGYW_PrEPDATA,PERSISTED_noprep,Months_3to6_since_initiation_t1,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(671,AGYW_PrEPDATA,PERSISTED_noprep,Months_6plus_since_initiation_t1,%STR(Kisumu),%STR());

%ODDS_RATIOS_GEE(672,AGYW_PrEPDATA,PERSISTED_noprep,primary,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(673,AGYW_PrEPDATA,PERSISTED_noprep,secondary,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(674,AGYW_PrEPDATA,PERSISTED_noprep,secondaryplus,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(675,AGYW_PrEPDATA,PERSISTED_noprep,Student_current_t1,%STR(Kisumu),%STR());
%ODDS_RATIOS_GEE(676,AGYW_PrEPDATA,PERSISTED_noprep,PrEP_adherencesupport,%STR(Kisumu),%STR());
DATA ORs_uni_t2_persist_gee_TFV10;SET OR641 OR642 OR643 OR644 OR645 OR646 OR647 OR648 OR649 OR650 OR651 OR652 OR653 OR654 
                             OR655 OR656 OR657 OR658 OR659 OR660 OR661 OR662 OR663 OR664 OR665 OR666 OR667 OR668
                             OR669 OR670 OR671 OR672 OR673 OR674 OR675 OR676;
length OR_ci_logistic_un $ 40;length OR_ci_gee_un $ 40;length OR_ci_gee_adj $ 40;
or_ci_logistic_un=catx('',round(or_logit,0.01),'[',round(ll_logit,0.01),',',round(ul_logit,0.01),']');
or_ci_gee_un=catx('',round(or_gee_unadj,0.01),'[',round(ll_gee_unadj,0.01),',',round(ul_gee_unadj,0.01),']');
or_ci_gee_adj=catx('',round(or_gee,0.01),'[',round(ll_gee,0.01),',',round(ul_gee,0.01),']');
P_gee_un=P_gee_unadj;
p_gee_adj=P_gee;
RUN;


DATA gee_select_t2_persist_TFV10;set ORS_uni_t2_persist_gee_TFV10;
where COVAR=1 AND P_gee_un LT 0.1;
KEEP NUM COVARIATE;
RUN;



%LET GEE_select_t2_persist_TFV10=
Q2Age_t1 
DREAMS_active_t2 
Partner_multiple_t2 
anykids 
Partner_knows_t2 
Partner_verysupportive_t2 
Partner_hasmultiplepartners_t2 
Partner_riskybehavior_t2 
HIVchance_modhigh_noprep_t2 
Contraceptive_injectable_t2 
Contraceptive_implant_t2 
Contraceptive_malecondom_t2 
PrEP_toldsomeone_t2 
Student_current_t1;


%GEE_MULTIVARIABLE(10,AGYW_PrEPDATA,PERSISTED_noprep,%STR(&GEE_select_t2_persist_TFV10));
DATA mgee_t2_persist_TFV10;SET select10; LENGTH COVARIATE $ 50.;
IF COVAR IN ('Q2AGE_T1' 'Q2Age_t1') THEN COVARIATE='Q2Age_t1';ELSE COVARIATE=COVAR; 
drop var covar num;
RUN;

PROC SORT DATA=mgee_t2_persist_TFV10;BY  COVARIATE;RUN;
PROC SORT DATA=gee_select_t2_persist_TFV10;BY  COVARIATE;RUN;
DATA ORS_mult_t2_persist_TFV10;MERGE gee_select_t2_persist_TFV10 mgee_t2_persist_TFV10;BY COVARIATE;RUN;

PROC SORT DATA=ORS_mult_t2_persist_TFV10;BY NUM  COVARIATE;RUN;
PROC SORT DATA=ORs_uni_t2_persist_gee_TFV10;BY NUM COVARIATE;RUN;
DATA ORS_geeres_t2_persist_TFV10;MERGE ORs_uni_t2_persist_gee_TFV10 ORS_mult_t2_persist_TFV10;BY NUM COVARIATE;RUN;


PROC REPORT DATA=ORS_geeres_t2_persist_TFV10 NOWD HEADLINE HEADSKIP CENTER MISSING;WHERE COVAR=1;
COLUMN COVARIATE N_0  N_1  (or_ci_gee_un P_gee_un or_ci_gee_mult P_gee_mult);
DEFINE COVARIATE/GROUP ORDER=DATA;
DEFINE N_0/GROUP 'N_0';
DEFINE N_1/GROUP 'N_1';
DEFINE or_ci_logistic_un/GROUP  'OR_logit';
DEFINE OR_ci_gee_un/GROUP  'OR_gee_un';
DEFINE OR_ci_gee_mult/GROUP  'OR_gee_mult';
DEFINE OR_ci_gee_adj/GROUP  'OR_ge_adj';
DEFINE Percent_0/GROUP FORMAT=5.2 'prct_0';
DEFINE Percent_1/GROUP FORMAT=5.2 'prct_1';
DEFINE P_logit/GROUP FORMAT=5.3 'P_logit';
DEFINE P_gee_un/GROUP FORMAT=5.3 'P_gee_un';
DEFINE P_gee_adj/GROUP FORMAT=5.3 'P_gee_adj';
DEFINE P_gee_mult/GROUP FORMAT=5.3 'P_gee_mult';
RUN;



/**************************************************************************************************/
/*******                                                                                     ******/
/**************************************************************************************************/



/**************************************************************************************************/
/*******                                                                                     ******/
/**************************************************************************************************/

